import routerConfig from '../../page/router';
import routerInit from 'miniapp-router';
Component({
  mixins: [],
  data: {
    videos_id:'',
    activeKey: 1,
    showModal1: true,
    showModal2: false,
    showModal3: false,
    showModal4: false,
    put_statu:true,
    video:'',
  },
  props: {},
  didMount() {
    routerInit.call(this, routerConfig);  //跳转页面初始化
    var params = this.$page.$router.params;
    console.log(this.$page.$router.params)
    this.setData({
      videos_id:params.videos_id
    })
    // this.getaty(1);
    this.getVideos_id(params.videos_id)
  },
  didUpdate() {},
  didUnmount() {},
  methods: {
    //获取视频id查询相关信息
    getVideos_id(id){
      var apiurl = 'App.ShopRedsVideo.GetLists';
      var params = {
        "page": 1,
        "pagesize": 1,
        videos_id:id
      };
      var app = getApp();
      var self = this;
      app.xdapis(apiurl, params, function (e) {
        my.hideLoading();
        // my.alert({ title: JSON.stringify(e) });
        console.log(e.list);
        self.setData({
          video: e.list[0].video,
        });
      });
    },
    // 视频投放
    videoPut(e){
      console.log(e);
      var id = e.target.dataset.id;
      console.log(id);
      var apiurl = 'App.ShopRedsVideo.Put';
      var params = {
        "type": '1,2,3',
        videos_id:this.data.videos_id
      };
      var app = getApp();
      var self = this;
      app.xdapis(apiurl, params, function (res) {
        my.hideLoading();
        console.log(res);
        if(res == 1){
          my.alert({
            content: '投放成功！'
          });
          self.setData({
            put_statu: false
          });
        }
        
      });
    },
    //复制
    myCopy() {
      var that = this;
        my.setClipboard({
        text: that.data.video, // 剪贴板数据
        success: (res) => {
          console.log(res);
          my.alert({
            content: '复制成功！'
          });
        },
      });
    },
    //打开新页面
    openNew(){
       let $router = this.$page.$router;
      $router.push(`/api/vd-create/yangkun/23`);
    },
    tabsActive(e) {
      var id = e.detail.value;
      this.setData({
        showModal1: false,
        showModal2: false,
        showModal3: false,
        showModal4: false,
      });
      switch (id) {
        case "1":
          this.setData({
            showModal1: true,
          })
          break;
        case "2":
          this.setData({
            showModal2: true,
          })
          break;
        case "3":
          this.setData({
            showModal3: true,
          })
          break;
        case "4":
          this.setData({
            showModal4: true,
          })
          break;
      }
    },
  },
  
});
